#include "uart.h"
#include "led.h"
//#include "clock.h"

void delay(volatile unsigned int t)
{
	volatile unsigned int t2;
	while(t--) for(t2 = 0xFFFF; t2; t2--);
}

char gString[] = "test";
int j = 0;

int main(void)
{
	char c = 0;
	int i,led;

	//	clock_init();	
	led_init();
	uart_init();

	for(i=0; i<4; i++)	//LED闪两下，说明程序已运行
	{
		for(led=0; led<4;led++) led_toggle(led);
		delay(0xFF);
	}

	puts("UART Test in S3C6410");
	puts("Reloate");
	puts(gString);
	puts("1.LED1 Toggle");
	puts("2.LED2 toggle");
	puts("Please select 1 or 2 to Toggle the LED");

	while(1)
	{
		c = getchar();	// 从串口终端获取一个字符
		putchar(c);
		putchar('\r');
		
		if(c == '1') led_toggle(0);
		else if(c == '2') led_toggle(1);
		
		j++;
		putchar(j%10 + '0');
	}
	
	return 0;
}
